package com.skyolder.milkbee.service;

import com.skyolder.milkbee.domain.Factor;
import com.skyolder.milkbee.repository.FactorRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;

import javax.inject.Inject;
import java.util.List;

/**
 * Service Implementation for managing Factor.
 */
@Service
@Transactional
public class FactorService {

    private final Logger log = LoggerFactory.getLogger(FactorService.class);
    
    @Inject
    private FactorRepository factorRepository;

    /**
     * Save a factor.
     *
     * @param factor the entity to save
     * @return the persisted entity
     */
    public Factor save(Factor factor) {
        log.debug("Request to save Factor : {}", factor);
        Factor result = factorRepository.save(factor);
        return result;
    }

    /**
     *  Get all the factors.
     *  
     *  @param pageable the pagination information
     *  @return the list of entities
     */
    @Transactional(readOnly = true) 
    public Page<Factor> findAll(Pageable pageable) {
        log.debug("Request to get all Factors");
        Page<Factor> result = factorRepository.findAll(pageable);
        return result;
    }

    /**
     *  Get one factor by id.
     *
     *  @param id the id of the entity
     *  @return the entity
     */
    @Transactional(readOnly = true) 
    public Factor findOne(Long id) {
        log.debug("Request to get Factor : {}", id);
        Factor factor = factorRepository.findOne(id);
        return factor;
    }

    /**
     *  Delete the  factor by id.
     *
     *  @param id the id of the entity
     */
    public void delete(Long id) {
        log.debug("Request to delete Factor : {}", id);
        factorRepository.delete(id);
    }
}
